/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * RSPrimitiveElement.cpp
 *
 *  Created on: 2010/02/25
 *      Author: Alexandre Pires ( c.alexandre.pires@gmail.com )
 */

#include "RSPrimitivesElement.h"

namespace Realsphere {

    RSPrimitivesElement::RSPrimitivesElement ( RSPrimitivesElementType rPrimitivesElementType, const QString& rName ) :
                RSElement ( RSPrimitivesElement::PrimitivesElementTypeToTag ( rPrimitivesElementType ) )
    {
        mPrimitivesElementType = rPrimitivesElementType;
        SetName ( rName, false );
    }

    RSPrimitivesElement::~RSPrimitivesElement ()
    {
    }

    RSPrimitivesElementType RSPrimitivesElement::PrimitivesElementType ()
    {
        return mPrimitivesElementType;
    }

    QString RSPrimitivesElement::PrimitivesElementTypeToTag ( RSPrimitivesElementType rPrimitivesElementType )
    {
        switch ( rPrimitivesElementType )
        {
            case RS_LINES:
                return QString ( RS_LINES_TAG );
                break;
            case RS_LINESTRIPS:
                return QString ( RS_LINESTRIPS_TAG );
                break;
            case RS_POLYGONS:
                return QString ( RS_POLYGONS_TAG );
                break;
            case RS_POLYLIST:
                return QString ( RS_POLYLIST_TAG );
                break;
            case RS_TRIANGLES:
                return QString ( RS_TRIANGLES_TAG );
                break;
            case RS_TRIFANS:
                return QString ( RS_TRIFANS_TAG );
                break;
            case RS_TRISTRIPS:
                return QString ( RS_TRISTRIPS_TAG );
                break;
            default:
                return QString ( RS_ELEMENT_TAG );
                break;
        }
    }

    RSPrimitivesElementType RSPrimitivesElement::PrimitivesElementTagToType ( const QString& rTag )
    {
        if ( rTag == RS_LINES_TAG )
        {
            return RS_PRIMITIVES_UNKNOWN;
        }
        else if ( rTag == RS_LINESTRIPS_TAG )
        {
            return RS_LINESTRIPS;
        }
        else if ( rTag == RS_POLYGONS_TAG )
        {
            return RS_POLYGONS;
        }
        else if ( rTag == RS_POLYLIST_TAG )
        {
            return RS_POLYLIST;
        }
        else if ( rTag == RS_TRIANGLES_TAG )
        {
            return RS_TRIANGLES;
        }
        else if ( rTag == RS_TRIFANS_TAG )
        {
            return RS_TRIFANS;
        }
        else if ( rTag == RS_TRISTRIPS_TAG )
        {
            return RS_TRISTRIPS;
        }

        return RS_PRIMITIVES_UNKNOWN;
    }
}
